home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club 2000 October / Software of the Month - Ultimate Collection Shareware 277.iso / pc / PROGRAMS / UTILITY / WINLINUX / DATA1.CAB / programs_-_include / LINUX / RAID5.H < prev    next >
C/C++ Source or Header  |  1999-09-17  |  3KB  |  111 lines

  1. #ifndef _RAID5_H
  2. #define _RAID5_H
  3.  
  4. #ifdef __KERNEL__
  5. #include <linux/md.h>
  6. #include <asm/atomic.h>
  7.  
  8. struct disk_info {
  9.     kdev_t    dev;
  10.     int    operational;
  11.     int    number;
  12.     int    raid_disk;
  13.     int    write_only;
  14.     int    spare;
  15. };
  16.  
  17. struct stripe_head {
  18.     struct stripe_head    *hash_next, **hash_pprev; /* hash pointers */
  19.     struct stripe_head    *free_next;        /* pool of free sh's */
  20.     struct buffer_head    *buffer_pool;        /* pool of free buffers */
  21.     struct buffer_head    *bh_pool;        /* pool of free bh's */
  22.     struct raid5_data    *raid_conf;
  23.     struct buffer_head    *bh_old[MD_SB_DISKS];    /* disk image */
  24.     struct buffer_head    *bh_new[MD_SB_DISKS];    /* buffers of the MD device (present in buffer cache) */
  25.     struct buffer_head    *bh_copy[MD_SB_DISKS];    /* copy on write of bh_new (bh_new can change from under us) */
  26.     struct buffer_head    *bh_req[MD_SB_DISKS];    /* copy of bh_new (only the buffer heads), queued to the lower levels */
  27.     int            cmd_new[MD_SB_DISKS];    /* READ/WRITE for new */
  28.     int            new[MD_SB_DISKS];    /* buffer added since the last handle_stripe() */
  29.     unsigned long        sector;            /* sector of this row */
  30.     int            size;            /* buffers size */
  31.     int            pd_idx;            /* parity disk index */
  32.     int            nr_pending;        /* nr of pending cmds */
  33.     unsigned long        state;            /* state flags */
  34.     int            cmd;            /* stripe cmd */
  35.     int            count;            /* nr of waiters */
  36.     int            write_method;        /* reconstruct-write / read-modify-write */
  37.     int            phase;            /* PHASE_BEGIN, ..., PHASE_COMPLETE */
  38.     struct wait_queue    *wait;            /* processes waiting for this stripe */
  39. };
  40.  
  41. /*
  42.  * Phase
  43.  */
  44. #define PHASE_BEGIN        0
  45. #define PHASE_READ_OLD        1
  46. #define PHASE_WRITE        2
  47. #define PHASE_READ        3
  48. #define PHASE_COMPLETE        4
  49.  
  50. /*
  51.  * Write method
  52.  */
  53. #define METHOD_NONE        0
  54. #define RECONSTRUCT_WRITE    1
  55. #define READ_MODIFY_WRITE    2
  56.  
  57. /*
  58.  * Stripe state
  59.  */
  60. #define STRIPE_LOCKED        0
  61. #define STRIPE_ERROR        1
  62.  
  63. /*
  64.  * Stripe commands
  65.  */
  66. #define STRIPE_NONE        0
  67. #define    STRIPE_WRITE        1
  68. #define STRIPE_READ        2
  69.  
  70. struct raid5_data {
  71.     struct stripe_head    **stripe_hashtbl;
  72.     struct md_dev        *mddev;
  73.     struct md_thread    *thread, *resync_thread;
  74.     struct disk_info    disks[MD_SB_DISKS];
  75.     struct disk_info    *spare;
  76.     int            buffer_size;
  77.     int            chunk_size, level, algorithm;
  78.     int            raid_disks, working_disks, failed_disks;
  79.     int            sector_count;
  80.     unsigned long        next_sector;
  81.     atomic_t        nr_handle;
  82.     struct stripe_head    *next_free_stripe;
  83.     int            nr_stripes;
  84.     int            resync_parity;
  85.     int            max_nr_stripes;
  86.     int            clock;
  87.     int            nr_hashed_stripes;
  88.     int            nr_locked_stripes;
  89.     int            nr_pending_stripes;
  90.     int            nr_cached_stripes;
  91.  
  92.     /*
  93.      * Free stripes pool
  94.      */
  95.     int            nr_free_sh;
  96.     struct stripe_head    *free_sh_list;
  97.     struct wait_queue    *wait_for_stripe;
  98. };
  99.  
  100. #endif
  101.  
  102. /*
  103.  * Our supported algorithms
  104.  */
  105. #define ALGORITHM_LEFT_ASYMMETRIC    0
  106. #define ALGORITHM_RIGHT_ASYMMETRIC    1
  107. #define ALGORITHM_LEFT_SYMMETRIC    2
  108. #define ALGORITHM_RIGHT_SYMMETRIC    3
  109.  
  110. #endif
  111.